<div>

    <div class="row" style="padding: 0 20px 0;">
        <nodestr></nodestr>
    </div>

    <hr class="mv10 clear">

    <div class="panel"  ng-hide="saveHide">

        <div class="panel-heading">
            <h5 ng-if="!businessjobedit.copyjob">编辑作业</h5>
            <h5 ng-if="businessjobedit.copyjob">克隆作业</h5>
        </div>

        <div class="panel-body">

            <div class="form-horizontal">

                <form class="form-inline" name="searchForm" novalidate>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="form-group col-sm-10" style="padding: 0">
                                <label style="float: left;line-height: 34px;min-width: 90px;text-align: right;" for="jobName">作业名称：</label>
                                <input type="text" id="jobName" class="form-control" style="width: 50%"  ng-model="newjobname" >
                                <button class="btn btn-default" style="margin-left: 20%; font-size: 14px" ng-click="businessjobedit.hideGlobalVar()">
                                    全局变量设置
                                </button>
                                <button ng-show="businessjobedit.copyjob" class="btn btn-default" style="font-size: 14px;margin-right: 3px" ng-click="businessjobedit.cloneToNode()">
                                    克隆至目标节点
                                </button>
                            </div>
                        </div>
                        <div class="row" ng-show="businessjobedit.hashCloneNodes" style="padding-top: 10px;">
                            <div class="form-group col-sm-10" style="padding: 0">
                                <div class="panel-tabs">
                                    <label style="float: left;line-height: 29px;min-width: 90px;text-align: right;" for="jobName">克隆节点：</label>
                                    <table class="table-hover text-center table-condensed">
                                        <tbody>
                                        <tr style="font-weight: bold;font-size: 14px;color: red">
                                            <td ng-repeat="(n, node) in businessjobedit.hashCloneNodes">
                                                {{node.name}}
                                            </td>
                                        </tr>
                                        </tbody>

                                    </table>
                                </div>
                            </div>

                        </div>
                    </div>
                </form>

            </div>
        </div>
    </div>
    <div class="panel panel-default" ng-hide="globalVar">
        <div class="panel-heading">
            <h5>全局变量参数</h5>
        </div>
        <div class="panel-body" style="padding: 10px">
            <div class="panel-tabs">
                <table class="table table-hover text-center table-condensed">
                    <!--<table class="table table-hover text-center table-condensed">-->
                    <thead>
                    <tr>
                        <th style="text-align: center;">变量名称</th>
                        <th style="text-align: center;">变量默认值</th>
                        <th style="text-align: center;">变量描述</th>
                        <th style="text-align: center;">操作</th>
                    </tr>
                    </thead>
                    <tr ng-repeat="ss in businessjobedit.allVar">
                        <td ><input type="text" class="form-control input-global" ng-model="ss.name" ng-readonly="ss.id"></td>
                        <td ><input type="text" class="form-control input-global" ng-model="ss.value" ></td>
                        <td ><input type="text" class="form-control input-global" ng-model="ss.describe" ></td>
                        <td >
                            <button class="btn btn-danger btn-sm" ng-click="businessjobedit.delVar($index, ss)">删除</button>
                        </td>
                    </tr>
                </table>
                <button class="btn btn-primary col-sm-1" style="width: 5%;padding: 6px 12px" uib-tooltip="添加变量" ng-click="businessjobedit.addVar()"><i class="fa fa-plus"></i></button>
            </div>
        </div>
    </div>
    <div style="margin-bottom: 15px;"  ng-hide="saveHide">
        <button class="btn btn-success " ng-click="businessjobedit.createScriptJob()">
            <i class="glyphicon glyphicon-copy"></i> 添加脚本步骤</button>
        <button class="btn btn-primary" ng-click="businessjobedit.createScpJob()">
            <i class="glyphicon glyphicon-file"></i> 添加分发文件步骤</button>

        <button class="btn btn-primary" ng-click="businessjobedit.createApprovalJob()">
            <i class="fa fa-id-card"></i> 添加审批步骤</button>
    </div>

    <div ng-repeat="item in businessjobedit.allNewJob">
        <div ng-if="item.plugin_type == 'cmd'" class="panel panel-success">
            <div style="padding: 2px">
                <strong style="font-size: 15px">步骤.{{$index+1}}</strong>
                <button class="btn btn-success btn-xs" ng-click="businessjobedit.createScriptJob($index)" ng-hide="saveHide"><i class="fa fa-plus"></i>脚本</button>
                <button class="btn btn-primary btn-xs" ng-click="businessjobedit.createScpJob($index)" ng-hide="saveHide"><i class="fa fa-plus"></i>文件</button>
                <button class="btn btn-primary btn-xs" ng-click="businessjobedit.createApprovalJob($index)" ng-hide="saveHide"><i class="fa fa-plus"></i>审批</button>
            </div>
            <div class="panel-heading">
                <h5>脚本作业</h5>
            </div>
            <div class="panel-body" style="padding: 10px">
                <div class="panel-tabs">
                    <table class="table table-hover text-center table-condensed" style="margin-bottom: 0">
                        <!--<table class="table table-hover text-center table-condensed">-->
                        <thead>
                            <tr>
                                <th style="text-align: center;">作业名称</th>
                                <th style="text-align: center;">执行账户</th>
                                <th style="text-align: center;">服务器类型</th>
                                <th style="text-align: center;">脚本参数</th>
                                <th style="text-align: center;">操作</th>
                            </tr>
                        </thead>
                        <tr>
                            <td>{{item.name}}</td>
                            <td>{{item.user}}</td>
                            <td>{{item.node_type}}</td>
                            <td>{{item.scripts_argv}}</td>
                            <td>
                                <button class="btn btn-warning btn-sm" ng-hide="saveHide" ng-click="businessjobedit.editScript($index)">编辑</button>
                                <button class="btn btn-danger btn-sm" ng-hide="saveHide" ng-click="businessjobedit.deljobdata($index)">删除</button>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        <div ng-if="item.plugin_type == 'scp'" class="panel panel-primary">
            <div style="padding: 1px">
                <strong style="font-size: 15px">步骤.{{$index+1}}</strong>
                <button class="btn btn-success btn-xs" ng-click="businessjobedit.createScriptJob($index)" ng-hide="saveHide"><i class="fa fa-plus"></i>脚本</button>
                <button class="btn btn-primary btn-xs" ng-click="businessjobedit.createScpJob($index)" ng-hide="saveHide"><i class="fa fa-plus"></i>文件</button>
                <button class="btn btn-primary btn-xs" ng-click="businessjobedit.createApprovalJob($index)" ng-hide="saveHide"><i class="fa fa-plus"></i>审批</button>
            </div>
            <div class="panel-heading">
                <h5>文件作业</h5>
            </div>
            <div class="panel-body"  style="padding: 10px">
                <div class="panel-tabs">
                    <table class="table table-hover text-center table-condensed" style="margin-bottom: 0;width: 100%">
                        <thead>
                            <tr>
                                <th style="text-align: center;">作业名称</th>
                                <th style="text-align: center;">执行账户</th>
                                <th style="text-align: center;max-width:600px;">目标服务器</th>
                                <th style="text-align: center;">目标路径</th>
                                <th style="text-align: center;">操作</th>
                            </tr>
                        </thead>
                        <!--<table class="table table-hover text-center table-condensed">-->
                        <tbody>
                            <tr>
                                <td >{{item.name}}</td>
                                <td >{{item.user}}</td>
                                <td style="max-width:600px;">{{item.dst}}</td>
                                <td >{{item.dp}}</td>
                                <td >
                                    <button class="btn btn-warning btn-sm" ng-hide="saveHide" ng-click="businessjobedit.editScp($index)">编辑</button>
                                    <button class="btn btn-danger btn-sm" ng-hide="saveHide" ng-click="businessjobedit.deljobdata($index)">删除</button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <div ng-if="item.plugin_type == 'approval'" class="panel panel-primary">
            <div style="padding: 1px">
                <strong style="font-size: 15px">步骤.{{$index+1}}</strong>
                <button class="btn btn-success btn-xs" ng-click="businessjobedit.createScriptJob($index)" ng-hide="saveHide"><i class="fa fa-plus"></i>脚本</button>
                <button class="btn btn-primary btn-xs" ng-click="businessjobedit.createScpJob($index)" ng-hide="saveHide"><i class="fa fa-plus"></i>文件</button>
                <button class="btn btn-primary btn-xs" ng-click="businessjobedit.createApprovalJob($index)" ng-hide="saveHide"><i class="fa fa-plus"></i>审批</button>
            </div>
            <div class="panel-heading">
                <h5>审批作业</h5>
            </div>
            <div class="panel-body"  style="padding: 10px">
                <div class="panel-tabs">
                    <table class="table table-hover text-center table-condensed" style="margin-bottom: 0;width: 100%">
                        <thead>
                            <tr>
                                <th style="text-align: center;">作业名称</th>
                                <th style="text-align: center;">审批人</th>
                                <th style="text-align: center;max-width:600px;">审批内容</th>
                                <th style="text-align: center;">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td >{{item.name}}</td>
                                <td >{{item.approver}}</td>
                                <td style="max-width:600px;">{{item.cont}}</td>
                                <td >
                                    <button class="btn btn-warning btn-sm" ng-hide="saveHide" ng-click="businessjobedit.editApproval($index)">编辑</button>
                                    <button class="btn btn-danger btn-sm" ng-hide="saveHide" ng-click="businessjobedit.deljobdata($index)">删除</button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>



    </div>

    <hr class="mv10 clear">
    <div style="margin-bottom: 15px">
        <div style="margin-left: 40%;">

            <button ng-if="businessjobedit.copyjob" class="btn btn-warning" ng-click="businessjobedit.saveCloneData()">
                克隆作业
            </button>
            <button ng-if="!businessjobedit.copyjob" class="btn btn-warning" ng-hide="saveHide" ng-click="businessjobedit.saveCreateData()">
                保存作业
            </button>
            <button ng-if="!businessjobedit.copyjob" class="btn btn-danger"  ng-click="businessjobedit.runJob()" ng-disabled="saveOK">
                立即执行
            </button>
        </div>
    </div>

</div>
